package edu.winona.csclub.testing.generators;

import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

import edu.winona.csclub.testing.core.Command;
import edu.winona.csclub.testing.core.ConfigFile;
import edu.winona.csclub.testing.core.TestCase;
import edu.winona.csclub.testing.core.Variable;
import edu.winona.csclub.testing.utils.XmlUtils;

public class TestCaseGenerator {

	/**
	 * creates a testcase from a configuration with a given provider giving test
	 * values
	 * @param configFile
	 * @param provider
	 * @return
	 * @throws SAXException
	 * @throws IOException
	 */
	public static TestCase GenerateEnumTestCases(ConfigFile configFile,EnumProvider provider) throws SAXException, IOException{
		 
	      List<Command> commands = configFile.getCommands();
	      
	      // all tests, collection of each commands tests
	    
	      TestCase ret = new TestCase();
	      
	      for(Command command  : commands ){
	    	
	    	  provider.generateTests(command, ret);
	    	  
	      }
	      return ret;
	}
	
	
	@Test
	public void TestThisThingAddTwo(){
		try{
			TestCase res = GenerateEnumTestCases(new ConfigFile(new File("edu/winona/csclub/testing/testCode/AddTwoMinimal.xml")),new StupidCaseEnumProvider());
			System.out.println(res);
		}catch(Exception e){
			e.printStackTrace();
			Assert.fail(e.getMessage());
		}
	}
	
	
	@Test
	public void TestThisThingMultiply(){
		System.out.println("==");
		try{
			TestCase res = GenerateEnumTestCases(new ConfigFile(new File("edu/winona/csclub/testing/testCode/multiplyComprehensive.xml")),new StupidCaseEnumProvider());
			System.out.println(res);
		}catch(Exception e){
			e.printStackTrace();
			Assert.fail(e.getMessage());
		}
		System.out.println("==");
	}
	
	
}
